package 工厂模式.简单工厂.controller;

import 工厂模式.简单工厂.entity.AwardInfo;
import 工厂模式.简单工厂.entity.ResponseResult;
import 工厂模式.简单工厂.service.IFreeGoods;
import 工厂模式.简单工厂.service.factory.FreeGoodsFactory;

import java.util.HashMap;

/**
 * 发放奖品
 */
public class DeliverController {

    public static void main(String[] args) {
        AwardInfo awardInfo = new AwardInfo();
        awardInfo.setUid("1001");
        awardInfo.setAwardTypes(2);
        awardInfo.setAwardNumber("SMS10001");
        HashMap<String, String> map = new HashMap<>();
        map.put("username","王五");
        map.put("phone","123456789");
        map.put("address","北京");
        awardInfo.setExtMap(map);
        awardToUser(awardInfo);
    }

    public static ResponseResult awardToUser(AwardInfo awardInfo) {

        IFreeGoods freeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardTypes());
        return freeGoods.sendFreeGoods(awardInfo);
    }
}
